<!doctype html>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/modules/cms/front/include/taglib.jsp"%>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>山东林业扶贫项目</title>
  <meta name="description" content="山东林业扶贫项目">
  <meta name="keywords" content="index">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="${ctxStatic}/sdlyfp/i/favicon.png">
  <link rel="apple-touch-icon-precomposed" href="${ctxStatic}/sdlyfp/i/app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="${ctxStatic}/sdlyfp/css/amazeui.min.css" />
  <link rel="stylesheet" href="${ctxStatic}/sdlyfp/css/admin.css">
  <link rel="stylesheet" href="${ctxStatic}/sdlyfp/css/app.css">
  <script src="${ctxStatic}/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
  <link rel="stylesheet" href="${ctxStatic}/sweetalert/sweetalert.css">
  <script src="${ctxStatic}/sweetalert/sweetalert.min.js"></script>
  <script src="${ctxStatic}/sdlyfp/js/base.js"></script>
  
</head>

<body data-type="generalComponents">
	
	<!-- 不是初始密码时，才加载头部 -->
	<c:if test="${fns:getUser().init ne 1}">
		<!-- head -->
		<jsp:include page="head.jsp" flush="false"></jsp:include>
	</c:if>
	
	<div class="tpl-page-container tpl-page-header-fixed">
	
	<!-- 不是初始密码时，才加载菜单 -->
	<c:if test="${fns:getUser().init ne 1}">
		<!-- 菜单 -->
		<jsp:include page="menu.jsp" flush="false"></jsp:include>
	</c:if>

        <div class="tpl-content-wrapper">
            <div class="tpl-content-page-title">
                密码修改
            </div>
            <ol class="am-breadcrumb">
                <li><a href="#" class="am-icon-home">首页</a></li> 
                <li class="am-active">密码修改</li>
            </ol>
            <div class="tpl-portlet-components">
                <div class="portlet-title">
                    <div class="caption font-green bold">
                        <span class="am-icon-code"></span> 密码修改
                    </div>
                    <div class="tpl-portlet-input tpl-fz-ml">
                        <div class="portlet-input input-small input-inline">
                            <div class="input-icon right">   
                                 </div>
                        </div>
                    </div>


                </div>
                <div class="tpl-block">

                    <div class="am-g">
                        <div class="tpl-form-body tpl-form-line">
                            <form class="am-form tpl-form-line-form" method="post" action="${ctx }/gt/gtUser/modifyPwd">
                            	
                            	<input type="hidden" id="menuId" name="menuId" value="${menuId }"/>
                            	
                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">原密码  </label>
                                    <div class="am-u-sm-9">
                                        <input type="password" name="oldPassword" class="tpl-form-input" id="oldPassword" placeholder="请输入原密码">
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label class="am-u-sm-3 am-form-label">新密码 <span class="tpl-form-line-small-title"> </span></label>
                                    <div class="am-u-sm-9">
                                        <input type="password" id="newPassword" name="newPassword" placeholder="请输入新密码">
                                        <small>新密码必须是字母和数字的组合且不能小于8位</small>
                                    </div>
                                </div>

                                 <div class="am-form-group">
                                    <label class="am-u-sm-3 am-form-label">确认新密码<span class="tpl-form-line-small-title"> </span></label>
                                    <div class="am-u-sm-9">
                                        <input type="password" id="confirmNewPassword" name="confirmNewPassword" placeholder="请再次输入新密码">
                                    </div>
                                </div>
                                
                                <!-- 是初始密码时，需要维护经办人信息 -->
                                <c:if test="${fns:getUser().init eq 1}">
	                                <div class="am-form-group">
	                                    <label class="am-u-sm-3 am-form-label">经办人姓名 <span class="tpl-form-line-small-title"> </span></label>
	                                    <div class="am-u-sm-9">
	                                        <input type="text" id="operName" name="operName" placeholder="请输入经办人姓名">
	                                    </div>
	                                </div>
	                                 <div class="am-form-group">
	                                    <label class="am-u-sm-3 am-form-label">经办人联系方式<span class="tpl-form-line-small-title"> </span></label>
	                                    <div class="am-u-sm-9">
	                                        <input type="text" id="mobile" name="mobile" placeholder="移动电话或者固定电话（4位区号+7/8电话号码）">
	                                        <small>手机或固定电话，固定电话格式：如0531-88888888</small>
	                                    </div>
	                                </div>
                                </c:if>

                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                        <button type="button" class="am-btn am-btn-primary tpl-btn-bg-color-success " onclick="doSubmit();">保存</button>
                                    	&nbsp;
                                    	<!-- 是初始密码时，增加更换账号登陆按钮 -->
                                    	<c:if test="${fns:getUser().init eq 1}">
		                                   <button type="button" class="am-btn am-btn-primary tpl-btn-bg-color-success " onclick="goBack('${ctx }/logout');">更换账号登陆</button>
		                                </c:if>
                                    </div>
                                </div>
                                
                            </form>

                        </div>
                    </div>
                </div>

                    </div>
                </div>
                <div class="tpl-alert"></div>
            </div>


        </div>

    </div>

  <script src="${ctxStatic}/sdlyfp/js/jquery.min.js"></script>
  <script src="${ctxStatic}/sdlyfp/js/amazeui.min.js"></script>
  <script src="${ctxStatic}/sdlyfp/js/app.js"></script>
</body>
<script type="text/javascript">

var isInit = "${fns:getUser().init}";
// 初始密码时，提示登陆后修改密码并完善相关信息
if('1' == isInit)
{
	msg("您的密码是初始密码，需要修改密码并完善信息后才可以访问并使用系统。修改密码后,请牢记您的新密码。",15000,"warning");
}

$(document).ready(function() {
	// $(".tpl-left-nav-menu").find("li a").eq(2).addClass("active");
	
	var menuId = '${menuId }';
	if(menuId)
	{
		$(".tpl-left-nav-menu").find("#"+menuId).addClass("active");
	}
	
	
	var message = "${message}";
	if(message)
	{
		var messageType = "${messageType}";
		msg(message,3000,messageType);
	}
});

function del(areaId)
{
	
	var content = "您确认要删除吗？";
	var url = ctx + "/gt/area/delete?id=" + areaId;
	comfirmMsg(content,url,"warning");
}

function doSubmit()
{
	if(isNull("原密码","oldPassword",'text')){return;}

	if(isNull("新密码","newPassword",'text',8)){return;}
	
	var newPassword = $("#newPassword").val();
	var regNumber = /\d+/; //验证0-9的任意数字最少出现1次。
	var regString = /[a-zA-Z]+/; //验证大小写26个字母任意字母最少出现1次。
	//验证第一个字符串
	if (regNumber.test(newPassword) && regString.test(newPassword)) {
	
	}else{
		msg("密码必须包含字母和数字，请重新输入。",15000,"warning");
		return;
	}
	
	if(isNull("确认新密码","confirmNewPassword",'text',8)){return;}
	var confirmNewPassword = $("#confirmNewPassword").val();
	if(newPassword != confirmNewPassword)
	{
		msg("您输入的新密码和确认密码不一致，请重新输入。",15000,"warning");
		return;
	}
	
	// 初始密码时校验经办人姓名和联系方式
	if('1' == isInit)
	{
		if(isNull("经办人姓名","operName",'text')){return;}
		var operName = $("#operName").val();
		if(!REG_NAME_ONLY.test(operName))
		{
			msg("姓名只能是汉字，请重新输入。",15000,"warning");
			return;
		}
		
		if(operName.length < 2)
		{
			msg("姓名长度不能少于2个汉字，请重新输入。",15000,"warning");
			return;
		}
		
		if(isNull("经办人联系方式","mobile",'mobile')){return;}
		
	}
	
	document.forms[0].submit();
}

</script>
</html>